package com.andfo.testframework;

import org.dbunit.database.IDatabaseConnection;

import javax.sql.DataSource;
import java.util.Properties;
import java.sql.Connection;

/**
 * Used to restore or backup files from the database.
 */
public interface DataStore {
    /**
     * Initiats the class and reads necessary properties.
     * @param properties
     */
    void init(Properties properties);

    /**
     * Restores a named backup.
     * @param restoreName
     */
    void loadRestoreFile(String restoreName);

    /**
     * Creates a named backup.
     * @param restoreName
     */
    void createRestoreFile(String restoreName);

    /**
     * Returns true if the backup file exists.
     * @param restoreName
     * @return
     */
    boolean restoreFileExists(String restoreName);

    /**
     * Returns a dbUnit connection in order to be able to restore a dbunit file
     * @return
     * @throws Exception
     */
    IDatabaseConnection createConnection() throws Exception;

    DataSource getDataSource();

    /**
     * This will drop and create a new database. This will ensure all tables, views etc are removed.
     */
    void recreateDb();
}
